#ifndef SERVER_H
#define SERVER_H

namespace fx {

    FX_DECLARE_CLASS(Session);
    FX_DECLARE_CLASS(Server);

    class Server
        : public boost::noncopyable
        , public boost::enable_shared_from_this<Server>
    {
    public:
        static ServerPtr Create(tcp::endpoint local_endpoint) ;

    public:
        void Start();
        void Stop();

        void HandleAccept(SessionPtr session, const boost::system::error_code& error);

    protected:
        Server(tcp::endpoint local_endpoint);

    private:
        tcp::endpoint endpoint_;
        tcp::acceptor acceptor_;
        bool is_running_;
    };

}

#endif//SERVER_H
